%%
%class JavascriptC

%line 
%column 
 

%standalone

%{

	public void print(String termo){
		System.out.println("termo: " + termo);
	}



%}


QuebraDeLinha		= \r|\n|\r\n

EspacoEmBranco		= {QuebraDeLinha}|[ \t\f]

Digito				= [0-9]

Digitos				= {Digito}{Digito}*

Fracopt				= "."{Digitos}?

Numero				= {Digitos}{Fracopt}?

Letra				= [A-Za-z]

Letras				= {Letra}{Letra}*
	
Id 					= {Letras}({Letras}|{Digitos})*

/*JavaScript Arithmetic Operators*/
Mult    			= "*"

Div             	= "/"

Soma            	= "+"

Sub             	= "-"

Mod					= "\%"
		
Inc					= "++"
		
Dec					= "--"

AriOp		        = ({Mult}|{Div}|{Soma}|{Sub}|{Mod}|{Inc}|{Dec})
/*JavaScript Arithmetic Operators*/

/*JavaScript Assignment Operators*/

Att			    	= "="
	
SomaAtt				= "+="
	
SubAtt				= "-="
	
MulAtt				= "*="
	
DivAtt				= "/="
	
ModAtt				= "\%="
	
AssOp				= "{Att}|{SomaAtt}|{SubAtt}|{MulAtt}|{DivAtt}|{ModAtt}"

/*JavaScript Assignment Operators*/

/*Comparison Operators*/

EQ					= "=="
		
EQQ					= "==="
		
NQ					= "!="
		
NQQ					= "!=="
		
GT					= ">"
		
LT					= "<"
		
GQ					= ">="
		
LQ					= "<="
		
ComOp				= ({EQ}|{EQQ}|{NQ}|{NQQ}|{GT}|{LT}|{GQ}|{LQ})

/*Comparison Operators*/

/*Logical Operators*/

AND					= "&&"
		
OR					= "||"
		
NOT					= "!"

/*Logical Operators*/

/*outros*/

Interrogacao		= "\?"
	
DoisPontos			= "\:"
	
AbrePar				= "("
	
FechaPar			= ")"
	
AbreChaves			= "{"
	
FechaChaves			= "}"
	
Virgula				= ","
	
AbreColchete		= "["
	
FechaColchete		= "]"
	
PontoVirgula		= "\;"
	
Ponto				= "."
	
AspasDuplas			= "\""
	
AspasSimples		= "\'"
	
AbreComentario		= "///"

/*outros*/

/*Palavras reservadas*/

if					= "if"
		
else				= "else"
		
switch				= "switch"
		
case				= "case"
		
break				= "break"
		
return				= "return"
		
function			= "function"
		
for					= "for"
		
abstract			= "abstract"

instanceof			= "instanceof"
	
super				= "super"
	
boolean				= "boolean"
	
enum				= "enum"
	
int					= "int"
	
export				= "export"
	
interface			= "interface"
	
synchronized		= "synchronized"
	
byte				= "byte"
	
extends				= "extends"
	
let					= "let"
	
this				= "this"
	
false				= "false"
	
long				= "long"
	
throw				= "throw"
	
catch				= "catch"
	
final				= "final"
	
native				= "native"
	
throws				= "throws"
	
char				= "char"
	
finally				= "finally"

new					= "new"

transient			= "transient"
	
class				= "class"
	
float				= "float"
	
null				= "null"
	
true				= "true"
	
const				= "const"

for					= "for"

package				= "package"

try					= "try"

continue			= "continue"
	
private				= "private"
	
typeof				= "typeof"
	
debugger			= "debugger"
	
goto				= "goto"
	
protected			= "protected"

var					= "var"

default				= "default"
	
public				= "public"
	
void				= "void"
	
delete				= "delete"
	
implements			= "implements"
	
volatile			= "volatile"
	
do					= "do"
	
import				= "import"
	
short				= "short"
	
while				= "while"
	
double				= "double"
	
in					= "in"
	
static				= "static"
	
with				= "with"

/*Palavras reservadas*/

%%

{EspacoEmBranco}    { /* nada */}

{QuebraDeLinha}		{ print(yytext()); }

{Digito}			{ print(yytext()); }

{Digitos}			{ print(yytext()); }

{Fracopt}			{ print(yytext()); }

{Numero}			{ print(yytext()); }

{Letra}				{ print(yytext()); }

{Letras}			{ print(yytext()); }
	
{Id} 				{ print(yytext()); }

{Mult}    			{ print(yytext()); }

{Div}             	{ print(yytext()); }

{Soma}            	{ print(yytext()); }

{Sub}             	{ print(yytext()); }

{Mod}				{ print(yytext()); }
		
{Inc}				{ print(yytext()); }
		
{Dec}				{ print(yytext()); }

{AriOp}		        { print(yytext()); }

{Att}			   	{ print(yytext()); }
	
{SomaAtt}			{ print(yytext()); }
	
{SubAtt}			{ print(yytext()); }
	
{MulAtt}			{ print(yytext()); }
	
{DivAtt}			{ print(yytext()); }
	
{ModAtt}			{ print(yytext()); }
	
{AssOp}				{ print(yytext()); }

{EQ}				{ print(yytext()); }
		
{EQQ}				{ print(yytext()); }
		
{NQ}				{ print(yytext()); }
		
{NQQ}				{ print(yytext()); }
		
{GT}				{ print(yytext()); }
		
{LT}				{ print(yytext()); }
		
{GQ}				{ print(yytext()); }
		
{LQ}				{ print(yytext()); }
		
{ComOp}				{ print(yytext()); }

{AND}				{ print(yytext()); }
		
{OR}				{ print(yytext()); }
		
{NOT}				{ print(yytext()); }

{Interrogacao}		{ print(yytext()); }
	
{DoisPontos}		{ print(yytext()); }
	
{AbrePar}			{ print(yytext()); }
	
{FechaPar}			{ print(yytext()); }
	
{AbreChaves}		{ print(yytext()); }
	
{FechaChaves}		{ print(yytext()); }
	
{Virgula}			{ print(yytext()); }
	
{AbreColchete}		{ print(yytext()); }
	
{FechaColchete}		{ print(yytext()); }
	
{PontoVirgula}		{ print(yytext()); }
	
{Ponto}				{ print(yytext()); }
	
{AspasDuplas}		{ print(yytext()); }
	
{AspasSimples}		{ print(yytext()); }
	
{AbreComentario}	{ print(yytext()); }

{if}				{ print(yytext()); }
		
{else}				{ print(yytext()); }
		
{switch}			{ print(yytext()); }
		
{case}				{ print(yytext()); }
		
{break}				{ print(yytext()); }
		
{return}			{ print(yytext()); }
		
{function}			{ print(yytext()); }
		
{for}				{ print(yytext()); }
		
{abstract}			{ print(yytext()); }

{instanceof}		{ print(yytext()); }
	
{super}				{ print(yytext()); }
	
{boolean}			{ print(yytext()); }
	
{enum}				{ print(yytext()); }
	
{int}				{ print(yytext()); }
	
{export}			{ print(yytext()); }
	
{interface}			{ print(yytext()); }
	
{synchronized}		{ print(yytext()); }
	
{byte}				{ print(yytext()); }
	
{extends}			{ print(yytext()); }
	
{let}				{ print(yytext()); }
	
{this}				{ print(yytext()); }
	
{false}				{ print(yytext()); }
	
{long}				{ print(yytext()); }
	
{throw}				{ print(yytext()); }
	
{catch}				{ print(yytext()); }
	
{final}				{ print(yytext()); }
	
{native}			{ print(yytext()); }
	
{throws}			{ print(yytext()); }
	
{char}				{ print(yytext()); }
	
{finally}			{ print(yytext()); }

{new}				{ print(yytext()); }

{transient}			{ print(yytext()); }
	
{class}				{ print(yytext()); }
	
{float}				{ print(yytext()); }
	
{null}				{ print(yytext()); }
	
{true}				{ print(yytext()); }
	
{const}				{ print(yytext()); }

{for}				{ print(yytext()); }

{package}			{ print(yytext()); }

{try}				{ print(yytext()); }

{continue}			{ print(yytext()); }
	
{private}			{ print(yytext()); }
	
{typeof}			{ print(yytext()); }
	
{debugger}			{ print(yytext()); }
	
{goto}				{ print(yytext()); }
	
{protected}			{ print(yytext()); }

{var}				{ print(yytext()); }

{default}			{ print(yytext()); }
	
{public}			{ print(yytext()); }
	
{void}				{ print(yytext()); }
	
{delete}			{ print(yytext()); }
	
{implements}		{ print(yytext()); }
	
{volatile}			{ print(yytext()); }
	
{do}				{ print(yytext()); }
	
{import}			{ print(yytext()); }
	
{short}				{ print(yytext()); }
	
{while}				{ print(yytext()); }
	
{double}			{ print(yytext()); }

{in}				{ print(yytext()); }
	
{static}			{ print(yytext()); }
	
{with}				{ print(yytext()); }

.                  	{ System.out.println("Erro: <"+yytext()+">");}